//
//  GridListModel.swift
//  BasicTools
//
//  Created by ikang on 2025/8/25.
//

import Foundation
import SwiftUI

public enum GridItemType {
    case itemHStack
    case itemVStack
}

@Observable public class GridItemModel {
    public var title: String = ""
    public var imageStr: String = ""
    
    public init(title: String, imageStr: String = "") {
        self.title = title
        self.imageStr = imageStr
    }
}

@Observable public class GridListModel {
    // 排列类型， image 和 title是横向排行，还是纵向排列
    public var itemType: GridItemType = .itemVStack
    // 每行的个数
    public var lineCount: Int = 5
    
    
    // 整体背景颜色
    public var backgroundColor: Color = .white
    // 最外层的padding
    public var gridPadding: EdgeInsets = EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)
    // 整体圆角
    public var gridCornerRadius: CGFloat = 0
    // 横向间距
    public var gridHSpace: CGFloat = 10
    // 纵向间距
    public var gridVSpace: CGFloat = 20
    
    public var titleFont: Font = .system(size: 15)
    public var titleColor: Color = .black
    public var selectTitleColor: Color = .clear
    public var imageSize: CGSize = CGSize(width: 40, height: 40)
    
    public var itemSpace: CGFloat = 0
    public var itemHeight: CGFloat = 0
    public var itemCornerRadius: CGFloat = 0
    // leading, trailing，应该不会起作用
//    public var itemPadding: EdgeInsets = EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)
    
    // 选中第几个
    public var selectIndex: Int = -1
    
    // 是否可以选中
    public var isCanSelect: Bool = false
    // 是否可以取消选中
    public var isCanCancelSelect: Bool = false
    
    public var itemBackgroundColor: Color = .clear 
    public var itemSelectBackgroundColor: Color = .clear
    
    public var itemBorderWidth: CGFloat = 0
    public var itemBorderColor: Color = .clear
    
    public var itemSelectBorderWidth: CGFloat = 0
    public var itemSelectBorderColor: Color = .clear
    
    public var itemArr: [GridItemModel] = []
    
    public init() {}
}


